package com.example.backend.mapper;

import com.example.backend.entity.Rider;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.ArrayList;

//映射器
@Repository
public interface RiderMapper {
    @Insert("insert into rider(name,pwd,phone,gzzt,gzsr,mark,state) values(#{name},#{pwd},#{phone},#{gzzt},#{gzsr},#{mark},#{state})")
    int addRider(Rider rider);

    @UpdateProvider(type = RiderMapperProvider.class, method = "getUpdateRiderSql")
    int updateRider(Rider rider);

    @Delete("delete from rider where id=#{id}")
    int deleteRiderById(Serializable id);

    @Select("select id,name,pwd,phone,gzzt,gzsr,mark,state from rider where id=#{id}")
    Rider selectRiderById(Serializable id);

    @Select("select id,name,pwd,phone,gzzt,gzsr,mark,state from rider where name=#{name} and pwd = #{pwd}")
    Rider selectRider(Rider rider);

    @SelectProvider(type = RiderMapperProvider.class, method = "getSelectRidersSql")
    ArrayList<Rider> selectRiders(Rider rider);

    @UpdateProvider(type = RiderMapperProvider.class, method = "getUpdateRiderScoreSql")
    int updateRiderScore(Integer id);
}

